"use client";
import ComContainer from "@/components/ComContainer";
import style from "./page.module.scss";
import Review, { ICommentRoot } from "@/components/Review";
import { IPostData } from "@/app/PostContentView/page";
import { TVideoData } from "@/app/Course/page";
import Details from "../Details";
import { TUserInfo } from "@/app/VedioContentView/page";
interface IContentView {
  data?: IPostData;
  vedioData?: TVideoData;
  reviewList?: ICommentRoot[];
  review?: string;
  setReview?: Function;
  onPublish?: () => void;
  textRef?: React.RefObject<HTMLDivElement>;
  textareaRef?: React.RefObject<HTMLDivElement>;
  handleReply?: (rootId: number, rvId: number, postId: number) => void;
  handleDel?: (commentId: number) => void;
  userInfo?: TUserInfo;
  courseUrl?: string;
  courseDesc?: string;
  contentCourse?: string;
  handleChangeValue?: (value: string) => void;
}
export default function ContentView(props: IContentView) {
  const {
    data,
    reviewList,
    review,
    setReview,
    onPublish,
    handleReply,
    vedioData,
    textRef,
    textareaRef,
    handleDel,
    userInfo,
    courseDesc,
    courseUrl,
    // contentCourse,
    // handleChangeValue,
  } = props;

  const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
    setReview?.(e.target.value);
  };
  const handleChangeValue = (value: string) => {
    console.log("value", value);
    setReview?.(value);
  };
  return (
    <ComContainer ContentWidth={800}>
      <div style={{ padding: "20px" }}>
        <Details
          data={data}
          vedioData={vedioData}
          userInfo={userInfo}
          courseUrl={courseUrl}
          courseDesc={courseDesc}
        ></Details>

        <div className={style["reviewContainer"]}>
          <Review
            value={review}
            // onChange={handleChange}
            handleChangeValue={handleChangeValue}
            reviewList={reviewList}
            onPublish={onPublish}
            handleReply={handleReply}
            textareaRef={textareaRef}
            textRef={textRef}
            handleDel={handleDel}
            isAuthor={data?.isAuthor || vedioData?.authorId}
          />
        </div>
      </div>
    </ComContainer>
  );
}
